package org.iabako.client.ui.form.business.product;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import org.iabako.client.tools.DefaultSuggestHandler;
import org.iabako.client.ui.form.business.SearchForm;
import org.iabako.client.ui.layout.widget.datatable.DataTable;
import org.iabako.shared.iservice.business.ProductServiceAsync;

/**
 * Created by jose on 16/01/15.
 */
public class ProductSearchForm extends Composite {

    @UiTemplate("org.iabako.client.ui.form.business.SearchForm.ui.xml")
    interface SearchFormTemplate extends UiBinder<HTMLPanel, SearchForm> {
    }

    private static final SearchFormTemplate binderSearchForm = GWT.create(SearchFormTemplate.class);

    private final ProductServiceAsync productServiceAsync = ProductServiceAsync.Util.getInstance();

    SearchForm searchForm;

    public ProductSearchForm(DefaultSuggestHandler serviceSuggestHandler, DataTable dataTable) {
        searchForm = new SearchForm();
        HTMLPanel searchFormPanel = binderSearchForm.createAndBindUi(searchForm);
        searchForm.setProperties(productServiceAsync, serviceSuggestHandler, dataTable, "search_motor_product_principal_input_title");
        initWidget(searchFormPanel);
    }
}
